<template>
  <div class="head">
    <section class="top-fixed">
      <header class="top-hd">
        <a class="logo" :href="`http://m.kugou.com`" title="酷狗音乐"></a>
        <div class="download-app">
          <span>下载酷狗</span>
        </div>
        <a class="btn-search" href=""></a>
      </header>
      <section class="top-goback" v-if="showPanelPlayer">
        <p class="title">{{audio.title}}</p>
        <div class="goback" @click="hidePanelPlayer">
          <i></i>
        </div>
      </section>
      <nav class="top-nav" v-else>
        <ul>
          <li :class="{cur:index == nav_index}" v-for="(n,index) in nav">
            <span @click="goRouter(index)">{{n.name}}</span>
          </li>
        </ul>
      </nav>
    </section>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  name: 'home',
  data() {
    return {
      nav_index: 0,
      nav: [{
        name: '新歌'
      }, {
        name: '排行'
      }, {
        name: '歌单'
      }, {
        name: '歌手'
      }]
    }
  },
  computed: {
    ...mapGetters(['showPanelPlayer','audio'])
  },
  methods: {
    goRouter(index) {
      // this.$store.commit('setHeadNav', index);
      switch (index) {
        case 0:
          this.$router.push({ path: 'home' });
          this.nav_index = 0;
          break;
        case 1:
          this.$router.push({ path: 'rank' });
          this.nav_index = 1;
          break;
        case 2:
          this.$router.push({ path: 'plist' });
          this.nav_index = 2;
          break;
        case 3:
          this.$router.push({ path: 'singer' });
          this.nav_index = 3;
          break;
      }
    },
    hidePanelPlayer() {
      this.$store.commit('showPanelPlayer', false);
    }
  }
}
</script>

<style lang="stylus"  scoped>
  .top-fixed
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    z-index: 3;
  // header
  .top-hd
    width:100%;
    padding-top:.0357rem;
    height:3.2143rem;
    line-height:3rem;
    background:#2ca2f9;
    text-align: left;
    position:relative;
    .logo
      display: inline-block;
      width: 7.286rem;
      height: 1.67857rem;
      margin-left: .7143rem;
      vertical-align: middle;
      background: url(../../assets/images/index/logo.png) no-repeat;
      background-size: 100%;
    .download-app
      display: inline-block;
      vertical-align: middle;
      span
        width: 5.7143rem;
        height: 1.7143rem;
        line-height: 1.7143rem;
        margin-left: .7143rem;
        border: 1px solid #fff;
        border-radius: .3571rem;
        display: block;
        text-align: center;
        color: #fff;
        font-size: .8571rem;
        font-family: Microsoft Yahei;
    .btn-search
      width: 1.2143rem;
      height: 1.2143rem;
      position: absolute;
      background: url(../../assets/images/index/search.png) no-repeat;
      background-size: 100%;
      top: 1rem;
      right: .7143rem;
      cursor: pointer;
  // nav
  .top-nav
    width: 100%;
    background: #fff;
    height: 3.2143rem;
    line-height: 3rem;
    box-shadow:0 0.1785rem 0.1785rem 0 #f4f4f4;
    ul
      width:100%;
      padding: 0 .7143rem;
      display:flex;
      box-sizing: border-box;
      li
        flex:1;
        &.cur
          span
            border-bottom: .2143rem solid #33a3f5;
        span
          border-bottom: .2143rem solid #fff;
          display: block;
          color: #333;
          font-size: 1.1429rem;
          box-sizing: border-box;
  .top-goback
    background: -webkit-linear-gradient(top,rgba(0,0,0,.6),transparent);
    height: 3rem;
    line-height: 3rem;
    padding: 0 2.1429rem;
    position: relative;
    text-align: center;
    color: #fff;
    box-sizing: border-box;
    .title
      height: 3rem;
      line-height: 3rem;
      font-size: 1rem;
    .goback
      width: 2.1429rem;
      height: 2.8031rem;
      position: absolute;
      top: 0;
      left: 0;
      text-align: center;
      cursor: pointer;
      i
        width: .85714rem;
        height: 1.42857rem;
        margin-top: .687265rem;
        display: inline-block;
        background: url(../../assets/images/index/goback_1.png) no-repeat;
        background-size: 100%;
</style>
